package JDBC;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//修改数据库数据预编译的方式
public class Test3 {
    public static void main(String[] args) throws SQLException {
        Connection connectMysql = ConnectMysql.getConnectMysql();
        String sql="update user  set name=? where user.userId=?";
        PreparedStatement preparedStatement = connectMysql.prepareStatement(sql);
        preparedStatement.setObject(1,"李四");
        preparedStatement.setObject(2,"108");

        //执行
        int i = preparedStatement.executeUpdate();
        System.out.println(i+"行受影响");
        preparedStatement.close();
        connectMysql.close();
    }
}
